#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>

int main() {
    int n, i, Product1 = 1, Product2 = 1, MaxProduct = INT_MIN;
    scanf("%d", &n);
    int* nums = (int*)malloc(sizeof(int)*n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", nums + i);
    }
    for (i = 0; i < n; i++)
    {
        if (Product1 * nums[i] >= 0)
        {
            Product1 *= nums[i];
            MaxProduct = max(Product1, MaxProduct);
        }
        else
        {
            Product2 *= (Product1 * nums[i]);
            MaxProduct = max(Product2, MaxProduct);
            Product1 = 1;
        }
    }
    printf("%d\n", MaxProduct);
    return 0;
}